/*
   @Copyright:Luogu
   @Author:   tjyemail
   @Problem:  https://www.luogu.com.cn/problem/P1003
   @Language: C++
   @Datetime: 20-08-13 14:07
   */

#include <bits/stdc++.h>
using namespace std;
struct Carpet {
	int a, b, g, k;
} C[10005];
int main()
{
	int n, x, y, c = -1;
	scanf("%d", &n);
	for(int i=0; i++<n;)
		scanf("%d %d %d %d", &C[i].a, &C[i].b, &C[i].g, &C[i].k);
	scanf("%d %d", &x, &y);
	for(int i=n; i>0; --i) {
		if (x>=C[i].a && x<=C[i].a+C[i].g && y>=C[i].b && y<=C[i].b+C[i].k) {
			c = i;
			break;
		}
	}
	printf("%d\n", c);
	return 0;
}
